import { ChannelListType } from '@/store/reducer/channel';
import request from '@/utils/request';

/** 获取所有频道列表 */
export const getChannelAPI = () =>
  request({
    url: '/v1_0/channels',
  });

/** 获取用户的频道 */
export const getUserChannelAPI = () =>
  request({
    url: '/v1_0/user/channels',
  });

/** 删除指定用户频道 */
export const delUserChannelAPI = (id: number) =>
  request({
    url: '/v1_0/user/channels/' + id,
    method: 'DELETE',
  });

/** 设置用户的频道（部分覆盖 */
export const addUserChannelAPI = (channels: ChannelListType) =>
  request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: channels,
    },
  });
